Minor typed IDs improvements: destructurers, ISpanParsable implementation and V7 Guid generation#813
Conversation
ISpanParsable\ implementation and V7 Guid generationISpanParsable implementation and V7 Guid generation
Summary
Skipped
🎉 No failed tests in this run. Github Test Reporter by CTRF 💚 🔄 This comment has been updated |
There was a problem hiding this comment.
Pull request overview
This PR implements ISpanParsable<TSelf> for typed IDs, adds destructuring methods for prefixed IDs, and updates GUID generation to use V7 (time-ordered) GUIDs. The changes modernize the typed ID implementation to support span-based parsing, improve API consistency with IFormatProvider parameters, and add convenient methods to extract components from prefixed IDs.
- Implementation of
ISpanParsable<TSelf>interface with bothReadOnlySpan<char>and string-based parsing methods - Addition of
Destructure()methods and raw value accessors (Guid,Ulid,ValuePart) for prefixed typed IDs - Migration from
Guid.NewGuid()toGuid.CreateVersion7()for time-ordered GUID generation
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Domain/LeanCode.DomainModels.Tests/LeanCode.DomainModels.Tests.csproj | Suppresses CA1305 (format provider) warnings for test project |
| test/Domain/LeanCode.DomainModels.Tests/Ids/RawStringTests.cs | Updates tests to use new Parse signature and adds comprehensive span-based parsing tests |
| test/Domain/LeanCode.DomainModels.Tests/Ids/PrefixedUlidTests.cs | Updates tests and adds Destructure test coverage and span-based parsing tests |
| test/Domain/LeanCode.DomainModels.Tests/Ids/PrefixedStringTests.cs | Updates tests for ValuePart property rename and adds Destructure test coverage |
| test/Domain/LeanCode.DomainModels.Tests/Ids/PrefixedGuidTests.cs | Adds tests for Guid property and Destructure method with span-based parsing tests |
| test/Domain/LeanCode.DomainModels.Tests/Ids/LongTests.cs | Adds comprehensive ISpanParsable implementation tests |
| test/Domain/LeanCode.DomainModels.Tests/Ids/IntTests.cs | Adds comprehensive ISpanParsable implementation tests |
| test/Domain/LeanCode.DomainModels.Tests/Ids/GuidTests.cs | Adds comprehensive ISpanParsable implementation tests |
| src/Helpers/LeanCode.UserIdExtractors/ServiceProviderExtensions.cs | Adds ISpanParsable constraint to TBacking generic parameter |
| src/Helpers/LeanCode.UserIdExtractors/Extractors/RawTypedUserIdExtractor.cs | Adds ISpanParsable constraint to TBacking generic parameter |
| src/Helpers/LeanCode.UserIdExtractors/Extractors/PrefixedTypedUserIdExtractor.cs | Updates Parse call to include null IFormatProvider parameter |
| src/Domain/LeanCode.DomainModels/Ids/TypedIdConverter.cs | Updates JSON converter Parse calls to include null IFormatProvider parameter |
| src/Domain/LeanCode.DomainModels/Ids/ITypedId.cs | Adds ISpanParsable interface and removes redundant static Parse method declarations |
| src/Domain/LeanCode.DomainModels.Generators/TypedIdGenerator.cs | Adds using statement for SourceBuilders namespace |
| src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/RawStringIdSourceBuilder.cs | New file with ISpanParsable implementation for raw string IDs |
| src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/RawIdSourceBuilder.cs | New file with ISpanParsable implementation for raw typed IDs (int, long, Guid) |
| src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/PrefixedUlidIdSourceBuilder.cs | New file with ISpanParsable, Destructure method, and Ulid property for prefixed ULID IDs |
| src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/PrefixedStringIdSourceBuilder.cs | New file with ISpanParsable, Destructure method, and ValuePart property for prefixed string IDs |
| src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/PrefixedGuidIdSourceBuilder.cs | New file with ISpanParsable, Destructure method, V7 Guid generation, and Guid property |
| src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/IdSource.cs | Refactored IdSource with V7 Guid generation support |
| src/Domain/LeanCode.DomainModels.Generators/IdSource.cs | Removed old IdSource file (refactored into SourceBuilders directory) |
| src/Domain/LeanCode.DomainModels.EF/TypedIdConverter.cs | Adds ISpanParsable constraint to TBacking generic parameter |
| src/Domain/LeanCode.DomainModels.EF/PropertiesConfigurationBuilderExtensions.cs | Adds ISpanParsable constraint to TBacking generic parameter |
| docs/domain/id/index.md | Documents new ISpanParsable interface, prefixed ID features, and updated API surface |
| CHANGELOG.md | Documents the ISpanParsable implementation and Destructure method additions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/PrefixedStringIdSourceBuilder.cs
Show resolved
Hide resolved
src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/RawStringIdSourceBuilder.cs
Show resolved
Hide resolved
src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/PrefixedGuidIdSourceBuilder.cs
Show resolved
Hide resolved
src/Domain/LeanCode.DomainModels.Generators/SourceBuilders/PrefixedUlidIdSourceBuilder.cs
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v10.0-preview #813 +/- ##
=================================================
+ Coverage 81.36% 84.60% +3.23%
=================================================
Files 231 236 +5
Lines 4648 4814 +166
Branches 345 342 -3
=================================================
+ Hits 3782 4073 +291
+ Misses 783 658 -125
Partials 83 83 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
be9c9d1 to
9dbea26
Compare
9dbea26 to
36e3571
Compare
Closes: CORELIB-70, CORELIB-163, CORELIB-388